#include <bits/stdc++.h>
#define ls (x << 1)
#define rs (x << 1 | 1)
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 2e7 + 10, INF = 0x3f3f3f3f;

int n, m;
string a, b;
int z[N], e[N];

void get_z()
{
    z[0] = m;
    int mid, mr = 0;
    for (int i = 1; i < m; i++) {
        int len = i < mr ? min(z[i - mid], mr - i) : 0;
        while (i + len < m && b[i + len] == b[len])
            len++;
        if (i + len > mr)
            mr = i + len, mid = i;
        z[i] = len;
    }
}

void get_e()
{
    int mid, mr = 0;
    for (int i = 0; i < n; i++) {
        int len = i < mr ? min(z[i - mid], mr - i) : 0;
        while (i + len < n && len < m && a[i + len] == b[len])
            len++;
        if (i + len > mr)
            mr = i + len, mid = i;
        e[i] = len;
    }
}

void solve()
{
    cin >> a >> b;
    n = a.length(), m = b.length();

    get_z();
    get_e();

    long long ans = 0;
    for (int i = 0; i < m; i++)
        ans ^= 1ll * (i + 1) * (z[i] + 1);
    cout << ans << endl;

    ans = 0;
    for (int i = 0; i < n; i++)
        ans ^= 1ll * (i + 1) * (e[i] + 1);
    cout << ans;
}

int main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    int T = 1;
    // cin>>T;
    for (int i = 1; i <= T; i++) {
        solve();
    }
}